/*
 * Copyright 2000-2020 ALPHA LAB.Inc All Rights Reserved.
 */
package com.alphalab.framework.test.queryTest;
 
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.alphalab.framework.role.GeneralQueryRole; 

/**
 * ProjectItemQueryRole.
 * @author allen 
 * @version 1.0.0 2017年12月25日
 */
@Service 
@Transactional
public class ProjectItemQueryRole extends 
	GeneralQueryRole<ProjectItemVo, ProjectItem, IProjectItemQueryDao, ProjectItemTransfer>  
		implements IProjectItemQueryRole {

	/**
	 * 初始化时注入projectItemQueryDao到projectItemQueryRole中.
	 * @param projectItemDao
	 */  
	@Autowired
	public void setprojectItemQueryDao(final IProjectItemQueryDao projectItemQueryDao) {
		super.setGeneralQueryDao(projectItemQueryDao);
	}
	
	/**
	 * 手动new一个转换器并set到父类中.
	 */
	@Override
	public ProjectItemTransfer getEntityTransfer() {
		try {
			return super.getEntityTransfer();
		} catch (RuntimeException e) { 
			super.setEntityTransfer(new ProjectItemTransfer());
		}
		return super.getEntityTransfer();
	}

	/**
	 * 获取项目额外信息.
	 * @param projectId projectId
	 * @return List<Map>
	 */ 
	public List<Map> getProjectItemExtendList(final String projectId) { 
		return getGeneralQueryDao().getProjectItemExtendList(projectId);
	}

	/**
	 * 获取项目信息.
	 * @param projectId projectId
	 * @param description description
	 * @param userName userName
	 * @return List<ProjectItemDetailVo>
	 */ 
	public List<ProjectItemDetailVo> getProjectItemDetailList(final String projectId,
			final String description, final String userName) {
		final ProjectItemDetailTransfer projectItemDetailTransfer = new ProjectItemDetailTransfer();
		return projectItemDetailTransfer.toVO(getGeneralQueryDao().
				getProjectItemDetailList(projectId, description, userName));
	}  
	
}
